package com.neusoft.his.sb;

import java.util.Date;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.neusoft.his.sb.util.SecretFilter;

@SpringBootApplication
// 声明mybatis需要处理的Mapper接口所在的包
@MapperScan("com.neusoft.his.sb.mapper")
@EnableTransactionManagement // 开启事务管理【可以省略，系统能够识别并处理】
@Configuration
public class Sb5Application {
//	向Springboot注册过滤器的方法
	@Bean
    public FilterRegistrationBean<SecretFilter> filterRegistrationBean() {
        FilterRegistrationBean<SecretFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new SecretFilter());	// 这里可以使用 new，也可以在 Filter 上加 @Component 注入进来
        bean.addUrlPatterns("/*"); //  设置过滤器的拦截范围
        bean.setName("secretFilter");
        bean.setOrder(0);	// 值越小，优先级越高
        System.out.println("Sb5Application.filterRegistrationBean()");
        return bean;
    } 
    public static void main(String[] args) {
        SpringApplication.run(Sb5Application.class, args);
        System.out.println("-----"+new Date()+"-----------------");
    }

}
 